<script setup>
//！24小时为例获取
import { getHotGoodsAPI } from '@/apis/detail'
import { computed, onBeforeUpdate, onMounted, ref } from 'vue'
import { onBeforeRouteUpdate, useRoute } from 'vue-router'
//！设计props
const props = defineProps({
    hotType: {
        type: Number
    }
})

const title = computed(() => {
    if (props.hotType == 1) {
        return '24小时热榜'
    }
    else {
        return '周热榜'
    }
})

const route = useRoute()
const hotList = ref([])
const getHostList = async () => {
    let res = await getHotGoodsAPI({
        id: route.params.id,
        type: props.hotType,
    })
    hotList.value = res.result
}
onMounted(() => {
    getHostList()
})
</script>


<template>
    <div class="goods-hot">
        <h3 style="background-color: #27bb9a;">{{ title }}</h3>
        <!-- 商品区块 -->
        <RouterLink :to="`/detail/${item.id}`" class="goods-item" v-for="item in hotList" :key="item.id" id="qwe">
            <img :src="item.picture" alt="" />
            <p class="name ellipsis">{{ item.name }}</p>
            <p class="desc ellipsis">{{ item.desc }}</p>
            <p class="price">&yen;{{ item.price }}</p>
        </RouterLink>
    </div>
</template>


<style scoped lang="scss">
#qwe:hover {
    transition: all .5s;
    transform: translate3d(0, -3px, 0);
    box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
}

.goods-hot {
    h3 {
        height: 70px;
        background: $helpColor;
        color: #fff;
        font-size: 18px;
        line-height: 70px;
        padding-left: 25px;
        margin-bottom: 10px;
        font-weight: normal;
    }

    .goods-item {
        display: block;
        padding: 20px 30px;
        text-align: center;
        background: #fff;

        img {
            width: 160px;
            height: 160px;
        }

        p {
            padding-top: 10px;
        }

        .name {
            font-size: 16px;
        }

        .desc {
            color: #999;
            height: 29px;
        }

        .price {
            color: $priceColor;
            font-size: 20px;
        }
    }
}
</style>